package com.itheima.excel.coverter;

import com.alibaba.excel.converters.AutoConverter;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;

/**
 * @author mrchen
 * @date 2022/3/19 23:42
 */
public class SexConverter extends AutoConverter {
    @Override
    public Object convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
        String stringValue = cellData.getStringValue();
        if ("男".equals(stringValue)) {
            return "0";
        }else {
            return "1";
        }
    }
    @Override
    public CellData convertToExcelData(Object value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
        if ("0".equals(value)) {
            return new CellData("男");
        }else {
            return new CellData("女");
        }
    }
}
